#ifndef DATA_DEVICE_H
#define DATA_DEVICE_H

class dataDevice
{
  int fd;

public:
  int getFd() const
  {
    return fd;
  }

  void setFd(int fd)
  {
    this->fd = fd;
  }
  virtual bool open() = 0;
  virtual ssize_t read(void *buffer, size_t size) = 0;
  virtual ssize_t write(const void *buffer, size_t size) = 0;
};

class ethernetDataDevice : public dataDevice
{
  char const * addr;
  int port;

public:
  //int getFd() const;
  ethernetDataDevice(char const * addr, int port);
  bool open();
  ssize_t read(void *buffer, size_t size);
  ssize_t write(const void *buffer, size_t size);
  ~ethernetDataDevice();
};

class serialDataDevice : public dataDevice
{
  //int fd;
  char const * serialName;

public:
  serialDataDevice(char const * serialName);
  bool open();
  ssize_t read(void *buffer, size_t size);
  ssize_t write(const void *buffer, size_t size);
  ~serialDataDevice();
};

#endif  //DATA_DEVICE_H
